package com.analystwatch.authentication.util;


import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class ConnectionUtil {
        private static ServiceRegistry serviceRegistry;
        private static SessionFactory sessionFactory;
        static {
                try {
                        Configuration configuration = new Configuration();
                        configuration.configure();
                        serviceRegistry = new ServiceRegistryBuilder().applySettings(
                                        configuration.getProperties()).buildServiceRegistry();
                        sessionFactory = configuration.buildSessionFactory(serviceRegistry);
                } catch (Throwable e) {
                        e.printStackTrace();
                }
        }

        public static SessionFactory getSessionFactory() {
                return sessionFactory;
        }
}